package com.papper.mng.controller.system;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.papper.common.utils.tool.DateTool;
import com.papper.common.utils.tool.StringTool;
import com.papper.mng.controller.BaseAction;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author:Lajiao
 * @Date:2014年8月21日
 * @Time:下午12:42:13
 * @Description:欢迎页面
 */
@Controller
public class WelcomeController extends BaseAction {

    @GetMapping(value = "/welcome")
    public String welcome(Model model, String stsDay) {
        if (StringTool.isEmpty(stsDay)) {
            stsDay = DateTool.formatDate(new Date(), DateTool.TRADITION_PATTERN);
        }
        model.addAttribute("stsDay", stsDay);
        Date                dStsDay  = DateTool.parseDate(stsDay, DateTool.TRADITION_PATTERN);
        Map<String, Object> conditon = Maps.newHashMap();
        conditon.put("ts", DateTool.getDayBegin(dStsDay));
        conditon.put("te", DateTool.getDayEnd(dStsDay));
        return render("system/welcome");
    }

    private List<Double> hourData(List<Map<String, Object>> map) {
        List<Double> lstHout = Lists.newArrayList();
        for (int i = 0; i < 24; i++) {
            lstHout.add(0d);
        }
        if (map != null) {
            for (Map<String, Object> key : map) {
                lstHout.set(StringTool.parseDouble(String.valueOf(key.get("dayHour")), 0d).intValue(), StringTool.parseDouble(StringTool.price(key.get("succPay")), 0d));
            }
        }
        return lstHout;
    }
}
